package com.example.b_308.myapplication.service;

import com.example.b_308.myapplication.comment.MedicalApplication;
import com.example.b_308.myapplication.comment.MedicalContent;
import com.example.b_308.myapplication.comment.MedicalResult;
import com.example.b_308.myapplication.comment.net.INetCallBack;
import com.example.b_308.myapplication.comment.utils.SharedPreferencesUtils;
import com.example.b_308.myapplication.model.Staff;
import com.example.b_308.myapplication.view.account.IAccountView;

/**
 * Created by B-308 on 2017/12/5.
 */
public class AccountService extends BaseService{

    static Staff accountDao;
    IAccountView iAccountView;

    public AccountService(IAccountView iAccountView) {
        this.iAccountView = iAccountView;
        accountDao = SharedPreferencesUtils.getObj(MedicalApplication.getMedicalApplication(), Staff.ACCOUNT_TAG, Staff.class);
        if (null == accountDao) {
            accountDao = new Staff();
        }
    }

    public void personal(Staff staff) {
        accountDao.getRequestHttp("/doctor/account/detail", staff, new INetCallBack() {
            @Override
            public void onNetCallBack(MedicalResult medicalResult) {
                if (MedicalContent.SUCCESS_CODE == medicalResult.code) {
                    accountDao = new Staff(medicalResult.data);
                    iAccountView.getAccountSuccess();
                } else {
                    iAccountView.fail(medicalResult.message);
                }
            }
        });
    }

}
